package cn.liu.jetpack_demo.components

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.size
import androidx.compose.foundation.layout.width
import androidx.compose.foundation.shape.CircleShape
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.unit.dp
import coil.compose.AsyncImage
import coil.request.ImageRequest

@Composable
fun CoilImageBox(url: String) {
  Box(
    modifier = Modifier
      .height(150.dp)
      .width(150.dp),
    contentAlignment = Alignment.Center,
  ) {
    AsyncImage(
      model = ImageRequest.Builder(LocalContext.current)
        .data(url)
        .crossfade(true)
        .build(),
      contentDescription = "coil image",
//      contentScale = ContentScale.Crop,
      modifier = Modifier
        .clip(CircleShape)
        .size(50.dp)
    )
  }
}

